<?php
  // 进行释放登录的验证
  // 知道到session验证一下是否存在userid这键即可
  // 引入封装好的验证登录的代码，调用
require_once '../common/functions.php';
checkLogin();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Categories &laquo; Admin</title>
  <link rel="stylesheet" href="../assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="../assets/vendors/font-awesome/css/font-awesome.css">
  <link rel="stylesheet" href="../assets/vendors/nprogress/nprogress.css">
  <link rel="stylesheet" href="../assets/css/admin.css">
  <script src="../assets/vendors/nprogress/nprogress.js"></script>
  <script src="../assets/vendors/jquery/jquery.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
    <!-- 这是公共模板 -->
    <?php include_once 'public/pub_nav.php'; ?>
    
    <div class="container-fluid">
      <div class="page-title">
        <h1>分类目录</h1>
      </div>
      <!-- 有错误信息时展示 -->
      <div class="alert alert-danger" style="display:none;">
        <span class="msg"></span>
      </div>
      <div class="row">
        <div class="col-md-4">
          <form id="form">
            <h2>添加新分类目录</h2>
            <div class="form-group">
              <label for="name">名称</label>
              <input id="name" class="form-control" name="name" type="text" placeholder="分类名称">
            </div>
            <div class="form-group">
              <label for="slug">别名</label>
              <input id="slug" class="form-control" name="slug" type="text" placeholder="slug">
              <p class="help-block">https://zce.me/category/<strong>slug</strong></p>
            </div>
            <div class="form-group">
              <label for="slug">图标</label>
              <input id="classname" name="classname" type="hidden" value="fa-glass">
              <div class="icons">
                <span class="fa fa-glass"></span>
                <div class="icons-contain">
                  <i class="closeBut fa fa-times"></i>
                  <div class="handle">请选择一个图标</div>
                  <div class="icons-outer">
                    <div class="icons-inner"></div>
                  </div>
                </div>
              </div>
            </div>
            <div class="form-group">
              <span class="btn btn-primary" id="add" data-toggle="modal" data-target="#modloginExit">添加</span>
              <div class="saves" style="display:none;">
                <span class="btn btn-primary" id="save" data-toggle="modal" data-target="#modloginExit">保存</span>
                <span class="btn btn-primary" id="cancle">取消</span>
              </div>
            </div>
          </form>
        </div>
        <div class="col-md-8">
          <div class="page-action">
            <!-- show when multiple checked -->
            <a class="btn btn-danger btn-sm" href="javascript:;" style="display: none" id="delAll">批量删除</a>
          </div>
          <table class="table table-striped table-bordered table-hover">
            <thead>
              <tr>
                <th class="text-center" width="40"><input type="checkbox" id="ckall"></th>
                <th>名称</th>
                <th>Slug</th>
                <th>图标</th>
                <th class="text-center" width="100">操作</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td class="text-center"><input type="checkbox"></td>
                <td>未分类</td>
                <td>uncategorized</td>
                <td>
                <span class="fa fa-gift"></span>
                </td>
                <td class="text-center">
                  <a href="javascript:;" class="btn btn-info btn-xs">编辑</a>
                  <a href="javascript:;" class="btn btn-danger btn-xs">删除</a>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>

  <?php include_once 'public/pub_aside.php' ?>
  
  
  <script src="../assets/vendors/bootstrap/js/bootstrap.js"></script>
  <script>NProgress.done()</script>
</body>
</html>
<!-- 添加模板 -->
<script type="text/template" id="categoryTp">
{{each $data value}}
<tr categoryid="{{value.id}}">
    <td class="text-center">
    <input type="checkbox">
    </td>
    <td>{{value.name}}</td>
    <td>{{value.slug}}</td>
    <td>
      <span class="fa {{value.classname}}"></span>
    </td>
    <td class="text-center">
      <a href="javascript:;" class="btn edit btn-info btn-xs">编辑</a>
      <a href="javascript:;" class="btn del btn-danger btn-xs">删除</a>
    </td>
</tr>
{{/each}}
</script>
<script src="/assets/vendors/art-template/template-web.js"></script>
<script src="/assets/js/admin/ad_categories.js"></script>
